<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MYMSGRO</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/meniu.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />

</h:head>
<h:body>

	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">

		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contenRight">

			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>My Books</a></li>
				</ul>
			</h:panelGroup>

			<h:panelGroup layout="block" id="contentTab">
				<h:form id="myBooksForm">
					<h:commandButton style="width: 17px;" image = "resources/img/view-refresh.png"
						action="#{bookTableData.refreshMyBooks}" />
					<br />
				<h:outputText value="You have no borrowed books"
						rendered="#{bookTableData.usersBookSize == 0}" />

					<p:dataTable id="myBooks" value="#{bookTableData.usersBooks}"
						var="book"
						rendered="#{bookTableData.usersBookSize > 0}" paginator="true" rows="5"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Book Title" />
							</f:facet>
							<h:inputText id="bookName" value="#{book.book.name}" size="20" styleClass="inputBooks"
								readonly="true" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Author" />
							</f:facet>
							<h:inputText id="author" value="#{book.book.author}" size="20" styleClass="inputBooks"
								readonly="true" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Domain" />
							</f:facet>
							<h:inputText id="domain" value="#{book.domain.name}" size="20" styleClass="inputBooks"
								readonly="true" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Year" />
							</f:facet>
							<h:inputText id="year" value="#{book.book.year}" size="20" styleClass="inputBooks"
								readonly="true" />
						</p:column>

					</p:dataTable>
					</h:form>
		</h:panelGroup>
<h:panelGroup layout="block" id="header2" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>Books I'm waiting for</a></li>
				</ul>
			</h:panelGroup>
<h:panelGroup layout="block" id="contentTab2">
			<h:form>
					<h:outputText value="You don't wait for any books."
						rendered="#{bookTableData.usersWaitingListSize == 0}" />
					<p:dataTable id="dt" value="#{bookTableData.usersWaitingList}"
						var="book" paginator="true" rows="5"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15"
						rendered="#{bookTableData.usersWaitingListSize > 0}">
						<p:column>

							<f:facet name="header">
								<h:commandLink
									action="#{bookTableData.usersWaitingList.sortByName}">
									<h:outputText value="Book title" />
								</h:commandLink>
							</f:facet>
							<h:outputText id="bookName" value="#{book.book.name}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:commandLink
									action="#{bookTableData.usersWaitingList.sortByAuthor}">
									<h:outputText value="Author" />
								</h:commandLink>
							</f:facet>
							<h:outputText id="author" value="#{book.book.author}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Domain" />
							</f:facet>
							<h:outputText id="domain" value="#{book.domain.name}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Year" />
							</f:facet>
							<h:outputText id="year" value="#{book.book.year}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Status" />
							</f:facet>
							<h:outputText id="status" value="#{book.book.status}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Remove from waiting list" />
							</f:facet>
							<h:commandButton value="Remove"
								actionListener="#{bookTableData.informDontNeedBook}">
								<f:attribute name="currentUserBookBean" value="#{book}" />
							</h:commandButton>
						</p:column>

					</p:dataTable>
				</h:form>
				</h:panelGroup>
				
			
		</h:panelGroup>
	</h:panelGroup>
</h:body>
</html>
